#pragma once

#include <gofcl_usart_ctl2.h>

typedef struct {
	u32_s error_inter_en : 1;
	u32_s irda_mode_en : 1;
	u32_s irda_low_power_en : 1;
	u32_s half_duplex_en : 1;
	u32_s nack_en : 1;
	u32_s smartcard_en : 1;
	u32_s dma_recv_en : 1;
	u32_s dma_trans_en : 1;
	u32_s rts_en : 1;
	u32_s cts_en : 1;
	u32_s cts_inter_en : 1;
	u32_s : 21;
} usart_ctl2_expl_s;

_Static_assert(sizeof(usart_ctl2_expl_s) == 4,
	       "Struct usart_ctl2_expl_s defined error!");

// 设置给定USART的配置2（即由CTL2寄存器配置的项）
static inline void usart_setup_2(usart_qe usart_q, usart_ctl2_expl_s ctl2) {
	union {
		usart_ctl2_expl_s e;
		usart_ctl2_s c;
	} ec = {
		.e = ctl2,
	};
	usart_wreg_ctl2_s(usart_q, ec.c);
}
